package com.tianruan.dc.modules.sys.user.mapper;

import com.tianruan.dc.modules.sys.user.entity.dto.WordLearnDTO;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface WordLearnMapper {
    /**
     * 分页查询单词
     * @param word
     * @return
     */
    List<WordLearnDTO> list(String word);

    /**
     * 修改背诵状态
     * @param word
     * @param flag
     */
    @Update("update t_isp_word set flag = case when flag = 1 then 0 else 1 end where word = #{word}")
    void updateFlag(String word, int flag);

    /**
     * 判断单词是否存在
     * @param word
     * @return
     */
    @Select("select * from t_isp_word where word = #{word}")
    String getWord(String word);
}
